import {request} from '../../utils/http'

Page({
  data: {
    curIdx: 0,
    height: 30,
    type: 'basis',
    animation: true,
    swipeable: true,
    titleSlot: false,
    plusSlot: true,
    sticky: false,
    tabs: [
      {
        title: '全部',
        subTitle: '描述文案',
        status: 0,
      },
      {
        title: '待支付',
        subTitle: '描述文案描述',
        status: 60
      },
      {
        title: '已付款',
        subTitle: '描述',
        status: 70
      },

      {
        title: '已取消',
        subTitle: '描述',
        status: -1
      },
    ],
    orderList: [],
    loading: false
  },
  // tabs 的点击回调
  handleChangeTab(e) {
    console.log('click', e)
    this.setData({
      curIdx: e,
    });
    this.fetch()
  },
  onLoad(query) {
    // 页面加载
    console.info(`Page onLoad with query: ${JSON.stringify(query)}`);
    this.fetch()
  },
  fetch() {
    this.loading = true
    request('/order/list', 'get', {status: this.data.tabs[this.data.curIdx].status,payMethod:1}).then(res => {
      this.setData({
        orderList: res.data
      })
      this.loading = false
    })
  },
  orderDetail(e) {
    const id = e.target.dataset.id
    my.navigateTo({ url: '../orderDetail/index?id=' + id + '&type=1'})
  }
});
